package com.core.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.core.entity.I_List;
import com.core.entity.ListEntity;

/**
 * 
 * @Description: TODO(自定义listview adapter的数据容器)
 * 
 * @author gufei 562401002@qq.com
 * 
 * @date 2015年3月17日 上午11:34:17
 */
public abstract class ListAdapter extends BaseAdapter {
	public List<I_List> lists;
	public Context context;
	public Holder holder;

	public LayoutInflater mInflater;

	public List<I_List> getLists() {
		return lists;
	}

	public void setLists(List<I_List> lists) {
		this.lists = lists;
	}

	public Context getContext() {
		return context;
	}

	public void setContext(Context context) {
		this.context = context;
		mInflater = LayoutInflater.from(context);
	}

	/**
	 * 
	 * @Title: instance
	 * 
	 * @Description: TODO(初始化Adapter约定的资源)
	 * 
	 * @param context
	 * @param list
	 * 
	 * @return ListAdapter
	 * 
	 */
	public ListAdapter instance(Context context, List<I_List> list) {
		setContext(context);
		setLists(list);
		return this;
	}

	public abstract View createView(int position, View convertView,
			ViewGroup parent);

	public ListAdapter() {
		super();
	}

	public ListAdapter(Context context, List<I_List> lists) {
		super();
		this.lists = lists;
		this.context = context;
	}

	@Override
	public int getCount() {
		return lists.size();
	}

	@Override
	public Object getItem(int arg0) {
		return arg0;
	}

	@Override
	public long getItemId(int arg0) {
		return arg0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		return createView(position, convertView, parent);
	}

}
